﻿<!DOCTYPE html>
<html lang="zh-Hans" xmlns:th="http://www.thymeleaf.org">
<th:block th:include="frontInclude :: frontHeader"/>
<body class="wel-body">
<header class="headerbox pcbox" th:replace="frontInclude :: header_menu"></header>
<div class="mbox" th:replace="frontInclude :: header_menu_mobile"></div>
<div class="con-banner">
    <div class="images pcbox"
         th:style="'background:url('+@{/img/banner3.jpg}+') no-repeat center;background-size: cover;'">
    </div>
    <img img class="mbox h500" th:src="@{/img/banner3.jpg}" alt="走进黑蝎">
    <div class="words">
        <div class="text w1280">
            <div class="tit-en tit-48 secwen">NEWS</div>
            <div class="tit-cn tit-36 secwen add1">黑蝎动态</div>
            <div class="line secwen add2"></div>
        </div>
    </div>
</div>
<div class="con-column secwen animate">
    <div class=" column-swiper w1280" data-s="7" data-l="6" data-m="3">
        <div class="swiper-container swiper-container-horizontal">
            <div class="swiper-wrapper">
                <div th:each="item : ${currentChildren}"
                     th:class="@{${item.active!=null && item.active==1?'swiper-slide-active':''}+' swiper-slide'}"
                     style="width: 155.571px;">
                    <a th:href="${item.pageUrl}"
                       th:class="@{${item.active!=null && item.active==1?'active':''}+' items'}">
                        <div class="span" th:text="${item.menuName}">黑蝎简介</div>
                    </a>
                </div>
            </div>
        </div>
        <div class="buts">
            <div class="swiper-button-prev swiper-button-disabled"></div>
            <div class="swiper-button-next swiper-button-disabled"></div>
        </div>
    </div>
</div>
<div class="attention-center con-swiper f-cb">
    <div class="content-with-nav w1280">
        <!-- 左侧目录导航 -->
        <div class="nav-sidebar" id="navSidebar">
            <div class="nav-title">动态目录</div>
            <ul class="nav-list" id="articleNav">
                <!-- 所有文章将通过JavaScript动态加载 -->
            </ul>
        </div>
        
        <!-- 右侧内容区域 -->
        <div class="content-area">
            <div class="article-list" id="articleList">
                <div th:each="item,iterStat : ${page.rows}" 
                     th:id="'article-' + ${item.id}" 
                     class="article-item secwen f-cb animate"
                     th:data-id="${item.id}"
                     th:data-src="${item.articleVideo}">
                    <a th:href="${'/front/articleView/'+item.id}" class="article-link">
                        <div class="img">
                            <img class="w100" th:src="${item.articleLogo}" th:alt="${item.articleTitle}">
                        </div>
                        <div class="words">
                            <div class="tit" th:text="${item.articleTitle}"></div>
                            <div class="j-span"></div>
                        </div>
                    </a>
                </div>
            </div>
            
            <!-- 分页 -->
            <div class="pagination-wrapper">
                <div class="text-center" th:replace="frontInclude :: pagination"></div>
            </div>
        </div>
    </div>
</div>

<!-- CSS样式 -->
<style>
.content-with-nav {
    display: flex;
    gap: 30px;
    align-items: stretch;
}

.nav-sidebar {
    width: 280px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 20px;
}

.nav-title {
    padding: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    border-bottom: 1px solid #f5f5f5;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: #f8f9fa;
    color: #e41e26;
    cursor: pointer;
}

.nav-link.active {
    background-color: #e41e26;
    color: #fff;
}

/* 预览模态框样式 */
.article-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.article-modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.article-modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #e41e26;
}

.modal-header {
    margin-bottom: 20px;
    padding-right: 30px;
}

.modal-title {
    font-size: 24px;
    color: #333;
    margin-bottom: 10px;
}

.modal-time {
    color: #999;
    font-size: 14px;
}

.modal-image {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 20px;
}

.modal-body {
    color: #666;
    line-height: 1.8;
    font-size: 16px;
}



.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.article-list {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.article-item {
    border-bottom: 1px solid #eee;
    scroll-margin-top: 20px;
}

.article-item:last-child {
    border-bottom: none;
}

.article-link {
    display: flex;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.3s ease;
}

.article-link:hover {
    background-color: #f8f9fa;
}

.article-item .img {
    width: 200px;
    height: 120px;
    margin-right: 20px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.article-item .words {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.article-item .tit {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    line-height: 1.5;
    margin-bottom: 10px;
}

.pagination-wrapper {
    margin-top: 30px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .nav-sidebar {
        width: 240px;
    }
    
    .content-with-nav {
        gap: 20px;
    }
}

@media (max-width: 1200px) {
    .nav-sidebar {
        width: 240px;
    }
}

@media (max-width: 768px) {
    .nav-sidebar {
        position: static;
        width: 100%;
        max-height: 200px;
        margin-bottom: 20px;
    }
    
    .content-with-nav {
        flex-direction: column;
        gap: 20px;
    }
    
    .article-link {
        flex-direction: column;
    }
    
    .article-item .img {
        width: 100%;
        height: 180px;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .modal-content {
        margin: 10px;
        padding: 20px;
        max-height: 90vh;
    }
}
</style>

<!-- JavaScript功能 -->
<script th:inline="javascript">
// 从后端获取当前菜单ID
window.currentMenuId = 16;
</script>
<script>
// 加载所有文章数据
function loadAllArticles() {
    // 获取当前菜单ID
    const currentUrl = window.location.href;
    const urlParams = new URLSearchParams(window.location.search);
    const category = urlParams.get('category') || 'hedt';
    
    // 请求所有文章数据
    fetch(`/front/listArticle?frontMenuId=${getCurrentMenuId()}&pageSize=10000&pageNum=1`)
        .then(response => response.json())
        .then(data => {
            renderArticleNav(data);
        })
        .catch(error => {
            console.error('加载文章失败:', error);
        });
}

// 获取当前菜单ID
function getCurrentMenuId() {
    // 从后端传递的数据中获取
    return window.currentMenuId || 8;
}

// 渲染文章导航
function renderArticleNav(articles) {
    const navList = document.getElementById('articleNav');
    navList.innerHTML = '';
    
    if (!articles || articles.length === 0) {
        navList.innerHTML = '<li style="padding: 20px; text-align: center; color: #999;">暂无文章</li>';
        return;
    }
    
    articles.forEach((article, index) => {
        const navItem = document.createElement('li');
        navItem.className = 'nav-item';
        
        const navLink = document.createElement('a');
        navLink.href = 'javascript:void(0)';
        navLink.className = 'nav-link';
        navLink.setAttribute('data-id', article.id);
        navLink.setAttribute('data-title', article.articleTitle);
        navLink.setAttribute('data-content', article.articleContent || article.articleDescribe || '暂无内容');
        navLink.setAttribute('data-logo', article.articleLogo || '');
        navLink.setAttribute('data-time', article.createTime || '日期未知');
        navLink.textContent = article.articleTitle;
        navLink.onclick = function(event) {
            event.preventDefault();
            window.location.href = '/front/articleView/' + article.id;
        };
        
        navItem.appendChild(navLink);
        navList.appendChild(navItem);
    });
}

// 显示文章预览模态框
function showArticlePreview(element) {
    const title = element.getAttribute('data-title');
    const content = element.getAttribute('data-content');
    const logo = element.getAttribute('data-logo');
    const time = element.getAttribute('data-time');
    
    // 创建模态框
    const modal = document.createElement('div');
    modal.className = 'article-modal';
    modal.style.cssText = `
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: rgba(0,0,0,0.8) !important;
        z-index: 9999 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    `;
    modal.innerHTML = `
        <div class="modal-content">
            <div class="modal-close" onclick="closeModal(this)">&times;</div>
            <div class="modal-header">
                <h3 class="modal-title">${title}</h3>
                <div class="modal-time">📅 ${time}</div>
            </div>
            ${logo ? `<img src="${logo}" alt="${title}" class="modal-image">` : ''}
            <div class="modal-body">${content}</div>
        </div>
    `;
    
    document.body.appendChild(modal);
    
    // 显示模态框
    setTimeout(() => {
        modal.style.opacity = '1';
        modal.style.visibility = 'visible';
        modal.classList.add('show');
    }, 10);
    
    // 点击背景关闭
    modal.addEventListener('click', function(e) {
        if (e.target === modal) {
            closeModal(modal.querySelector('.modal-close'));
        }
    });
}

// 关闭模态框
function closeModal(element) {
    const modal = element.closest('.article-modal');
    modal.classList.remove('show');
    setTimeout(() => {
        modal.remove();
    }, 300);
}

// 滚动到指定文章
function scrollToArticle(articleId) {
    const targetElement = document.getElementById('article-' + articleId);
    if (targetElement) {
        targetElement.scrollIntoView({
            behavior: 'smooth',
            block: 'start'
        });
        
        // 更新导航激活状态
        updateActiveNav(articleId);
    }
}

// 更新导航激活状态
function updateActiveNav(activeArticleId) {
    document.querySelectorAll('.nav-link').forEach(link => {
        if (link.getAttribute('data-id') == activeArticleId) {
            link.style.backgroundColor = '#e41e26';
            link.style.color = '#fff';
        } else {
            link.style.backgroundColor = '';
            link.style.color = '#666';
        }
    });
}

// 页面初始化
document.addEventListener('DOMContentLoaded', function() {
    // 加载所有文章数据
    loadAllArticles();
    
    // 监听滚动事件，更新导航激活状态
    window.addEventListener('scroll', function() {
        const articles = document.querySelectorAll('.article-item');
        let activeId = null;
        
        articles.forEach(article => {
            const rect = article.getBoundingClientRect();
            if (rect.top <= 100 && rect.bottom > 100) {
                activeId = article.getAttribute('data-id');
            }
        });
        
        if (activeId) {
            updateActiveNav(activeId);
        }
    });
});
</script>
<div th:replace="frontInclude :: footer"></div>
</body>
</html>